{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>OPS运维系统 | Lockscreen</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="shortcut icon" href="{% static 'favicon.ico' %}" type="image/x-icon">
    <link rel="icon" href="{% static 'favicon.ico' %}" type="image/x-icon">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" href="{% static 'AdminLTE/bower_components/bootstrap/dist/css/bootstrap.min.css' %}">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="{% static 'AdminLTE/bower_components/font-awesome/css/font-awesome.min.css' %}">
    <!-- Ionicons -->
    <link rel="stylesheet" href="{% static 'AdminLTE/bower_components/Ionicons/css/ionicons.min.css' %}">
    <!-- Theme style -->
    <link rel="stylesheet" href="{% static 'AdminLTE/dist/css/AdminLTE.min.css' %}">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

    <!-- Google Font -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition lockscreen">
<!-- Automatic element centering -->
<div class="lockscreen-wrapper">
    <div class="lockscreen-logo">
        <a href="javascript:void(0)"><b>OPS</b>运维管理系统</a>
    </div>
    <!-- User name -->
    <div class="lockscreen-name">{{ user.username }}</div>

    <!-- START LOCK SCREEN ITEM -->
    <div class="lockscreen-item">
        <!-- lockscreen image -->
        <div class="lockscreen-image">
            <img src="{{ MEDIA_URL }}{{ user.image }}" alt="User Image">
        </div>
        <!-- /.lockscreen-image -->

        <!-- lockscreen credentials (contains the form) -->
        <form class="lockscreen-credentials" action="{% url 'lock_screen' %}" method="post" id="lock_form">
            {% csrf_token %}
            <div class="input-group">
                <input type="password" class="form-control pwd" placeholder="password" name="pwd">

                <div class="input-group-btn">
                    <button type="submit" class="btn sub"><i class="fa fa-arrow-right text-muted"></i></button>
                </div>
            </div>
        </form>
        <!-- /.lockscreen credentials -->

    </div>
    <!-- /.lockscreen-item -->
    <div class="help-block text-center">
        {% if login_error_info %}
            <span class="text-red">{{ login_error_info }}</span>
        {% else %}
            Enter your password to retrieve your session
        {% endif %}
    </div>
    <div class="text-center">
        <a href="{% url 'login' %}">使用另一个用户登录</a>
    </div>
    <div class="lockscreen-footer text-center">
        Copyright &copy; 2014-2018 <b><a href="javascript:void(0)" class="text-black">OPS</a></b><br>
        All rights reserved
    </div>
</div>
<!-- /.center -->

<!-- jQuery 3 -->
<script src="{% static 'AdminLTE/bower_components/jquery/dist/jquery.min.js' %}"></script>
<!-- Bootstrap 3.3.7 -->
<script src="{% static 'AdminLTE/bower_components/bootstrap/dist/js/bootstrap.min.js' %}"></script>
<script src="{% static 'js/jsencrypt.min.js' %}"></script>

<script language="javascript">
    $(function () {
        $('.sub').on('click', function () {
            let pwd = $('.pwd');
            let en_pwd = encry_pwd(pwd.val());
            pwd.val(en_pwd);
            $('#lock_form').submit()
        });
    });

    //防止页面后退
    history.pushState(null, null, document.URL);
    window.addEventListener('popstate', function () {
        history.pushState(null, null, document.URL);
    });

    function encry_pwd(pwd) {
        let crypt = new JSEncrypt();
        crypt.setPublicKey(`{{ public_key }}`);

        // Encrypt the data with the public key.
        return crypt.encrypt(pwd)
    }
</script>

</body>
</html>
